import type { ResultData } from '@/types/commonType'
import type { IParams } from '@/types/loginType'
import type { MenuItem } from '@/types/munuType'
import type { CreateParams, EditParams, Params, UserItem } from '@/types/userType'
import request from '@/utils/request'

export default {
  login(params: IParams) {
    return request.post<string>('/users/login', params)
  },
  getUserInfo() {
    return request.get<UserItem>('/users/getUserInfo')
  },
  // 获取用户列表
  getUserList(params?: Params) {
    return request.get<ResultData<UserItem>>('/users/list', params)
  },
  // 用户添加
  userCreate(params: CreateParams) {
    return request.post('/users/create', params)
  },
  // 用户编辑
  userEdit(params: EditParams) {
    return request.post('/users/edit', params)
  },
  // 用户删除
  userDel(params: { userIds: number[] }) {
    return request.post('/users/delete', params)
  },
  // 获取全量用户列表
  getAllUserList(params?: Params) {
    return request.get<UserItem[]>('/users/all/list', params)
  },
  // 获取用户权限列表
  getPermissionList() {
    return request.get<{ buttonList: string[]; menuList: MenuItem[] }>('/users/getPermissionList')
  }
}
